package com.xidian.zhiancloud.service.myyb;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.SysProcessManagementMapper;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.SysProcessManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 流程管理
 */
@Service
public class IProcessManagementService extends ServiceImpl
        <SysProcessManagementMapper, SysProcessManagement> implements IService<SysProcessManagement>{

    @Autowired
    private SysProcessManagementMapper processManagementMapper;

    public List<SysProcessManagement> selectProcessManagementList(Map mapResult) {
        return processManagementMapper.selectProcessManagementList(mapResult);
    }

    public SysProcessManagement deleteProcessManagement(Long id) {
        return processManagementMapper.deleteProcessManagement(id);
    }

    public void patchById(SysProcessManagement processManagement) {
        int result = processManagementMapper.
                updateByPrimaryKeySelective(processManagement);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }

    public void add(SysProcessManagement processManagement) {
        int result = processManagementMapper.insert(processManagement);
        if (result == 0) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
    }

    public SysProcessManagement getById(Long id) {
        SysProcessManagement processManagement = processManagementMapper.selectByPrimaryKey(id);
        if (processManagement == null) {
            throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
        }
        return processManagement;
    }


}
